#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N=2e5;
#define INF 0x7fffffff
typedef long long int ll;
using namespace std;

int ans=0;
void solve()
{
	for(int i=1;i<=2019;i++)
	{
		for(int j=i+1;j<=2019;j++)
		{
			int a=i,b=j,c=2019-a-b;
			if(a==b||a==c||b==c||c<a||c<b) continue;
			auto ok = [](int num)->bool 
			{
				while(num)
				{
					if(num%10==2||num%10==4) return false;
					num/=10;
				}
				return true;
			};
			if(ok(a)&&ok(b)&&ok(c)) ans++;
		}
	}
	pd(ans);puts("");
}

int main()
{
	int T=1;
	//sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}